<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-title" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">封面:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-image" class="form-control" size="50" name="row[cover]" type="text"
                       value="{$row.cover|htmlentities}">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-image" class="btn btn-danger faupload"
                                  data-input-id="c-image"
                                  data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp"
                                  data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose"
                                  data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i
                            class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-image"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-image"></ul>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">作者:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-author" class="form-control" name="row[author]" type="text" value="{$row.author|htmlentities}">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">来源:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-source_url" class="form-control" name="row[source_url]" type="text"
                   value="{$row.source_url|htmlentities}">
        </div>
    </div>


    <div class="form-group">
        <label for="summary" class="control-label col-xs-12 col-sm-2">摘要:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea class="form-control" id="summary" name="row[summary]">{$row.summary|htmlentities}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label for="copyrighting" class="control-label col-xs-12 col-sm-2">文案:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea class="form-control" id="copyrighting" name="row[copyrighting]">{$row.copyrighting|htmlentities}</textarea>
        </div>
    </div>


    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:

        </label>
        <div class="col-xs-12 col-sm-8">

            <button type="button" class="btn btn-primary" onclick="changeModal(1)">1个图片</button>
            <button type="button" class="btn btn-primary" onclick="changeModal(2)">2个图片</button>
            <textarea id="c-content" class="form-control editor" data-nkeditor-options='' rows="5" name="row[content]"
                      cols="50">{$row.content|htmlentities}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
        </div>
    </div>
    <div id="hidden-div" style="display:none"></div>
</form>
<script>
    // https://mp.weixin.qq.com/s/EvdBFr-agi3KAjiALUXpOQ
    function changeModal(type) {
        // 夏日海滩壁纸,让清凉从屏幕开始，还有国风画壁纸哦
        var id = '{$row.id}';
        $.ajax({
            url: "wechat/articles/modal",
            type: 'post',
            dataType: 'json',
            data: {id: id,type:type},
            success: function (ret) {
                $('#hidden-div').html(ret);
                var content = $('#rendered-content').html();
                $('#c-content').html(content);
                $(".ke-container").children("div:eq(1)").children("iframe").contents().find('body').html(content);
                console.log(content)

            }, error: function (e) {

            }
        });
    }
</script>
